<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "tme_orderinfo".
 *
 * @property integer $ID
 * @property string $BillCode
 * @property integer $Uid
 * @property string $UserName
 * @property integer $TBa_ID
 * @property string $DeliveryName
 * @property integer $TAu_ID
 * @property string $OperID
 * @property integer $TMe_ID
 * @property string $OutBillCode
 * @property string $PostBillCode
 * @property string $BillStatus
 * @property string $OrderTime
 * @property string $RecMan
 * @property string $LinkTel
 * @property string $RecAddress
 * @property string $PostCode
 * @property double $TotalMoney
 * @property string $Remark
 *
 * @property TmeOrderdetailsinfo[] $tmeOrderdetailsinfos
 * @property TauOperinfo $tAu
 * @property TmeOutstockinfo $tMe
 * @property TbaMemberinfo $u
 * @property TbaDeliveryinfo $tBa
 */
class TmeOrderinfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'tme_orderinfo';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['BillCode', 'OrderTime', 'RecMan', 'LinkTel', 'RecAddress', 'PostCode'], 'required'],
            [['Uid', 'TBa_ID', 'TAu_ID', 'TMe_ID'], 'integer'],
            [['BillStatus'], 'string'],
            [['OrderTime'], 'safe'],
            [['TotalMoney'], 'number'],
            [['BillCode', 'OutBillCode'], 'string', 'max' => 30],
            [['UserName', 'DeliveryName', 'PostBillCode', 'RecMan', 'LinkTel'], 'string', 'max' => 20],
            [['OperID', 'PostCode'], 'string', 'max' => 6],
            [['RecAddress'], 'string', 'max' => 150],
            [['Remark'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'BillCode' => 'Bill Code',
            'Uid' => 'Uid',
            'UserName' => 'User Name',
            'TBa_ID' => 'Tba  ID',
            'DeliveryName' => 'Delivery Name',
            'TAu_ID' => 'Tau  ID',
            'OperID' => 'Oper ID',
            'TMe_ID' => 'Tme  ID',
            'OutBillCode' => 'Out Bill Code',
            'PostBillCode' => 'Post Bill Code',
            'BillStatus' => 'Bill Status',
            'OrderTime' => 'Order Time',
            'RecMan' => 'Rec Man',
            'LinkTel' => 'Link Tel',
            'RecAddress' => 'Rec Address',
            'PostCode' => 'Post Code',
            'TotalMoney' => 'Total Money',
            'Remark' => 'Remark',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTmeOrderdetailsinfos()
    {
        return $this->hasMany(TmeOrderdetailsinfo::className(), ['BillCode' => 'BillCode']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTAu()
    {
        return $this->hasOne(TauOperinfo::className(), ['ID' => 'TAu_ID', 'OperID' => 'OperID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTMe()
    {
        return $this->hasOne(TmeOutstockinfo::className(), ['ID' => 'TMe_ID', 'OutBillCode' => 'OutBillCode']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getU()
    {
        return $this->hasOne(TbaMemberinfo::className(), ['ID' => 'Uid', 'username' => 'UserName']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTBa()
    {
        return $this->hasOne(TbaDeliveryinfo::className(), ['ID' => 'TBa_ID', 'DeliveryName' => 'DeliveryName']);
    }
}
